<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商品管理系统</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background-color: white;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        h1, h2 {
            color: #333;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 12px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: inline-block;
            width: 120px;
            font-weight: bold;
        }
        input[type="text"], input[type="number"], select, textarea {
            width: 250px;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        textarea {
            height: 80px;
        }
        button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 15px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        button:hover {
            background-color: #45a049;
        }
        .error {
            color: red;
            margin-bottom: 15px;
        }
        .success {
            color: green;
            margin-bottom: 15px;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>商品管理系统</h1>

    <div id="message"></div>

    <!-- 添加商品表单 -->
    <h2>添加新商品</h2>
    <form id="productForm">
        <div class="form-group">
            <label for="productName">商品名称:</label>
            <input type="text" id="productName" name="productName" required>
        </div>

        <div class="form-group">
            <label for="typeId">商品类型:</label>
            <select id="typeId" name="typeId" required>
                <option value="">-- 请选择 --</option>
                <!-- 商品类型将通过JavaScript动态加载 -->
            </select>
        </div>

        <div class="form-group">
            <label for="price">价格:</label>
            <input type="number" id="price" name="price" step="0.01" min="0" required>
        </div>

        <div class="form-group">
            <label for="stock">库存:</label>
            <input type="number" id="stock" name="stock" min="0" value="0">
        </div>

        <div class="form-group">
            <label for="imageUrl">图片URL:</label>
            <input type="text" id="imageUrl" name="imageUrl">
        </div>

        <div class="form-group">
            <label for="status">状态:</label>
            <select id="status" name="status">
                <option value="active">上架</option>
                <option value="inactive">下架</option>
            </select>
        </div>

        <div class="form-group">
            <label for="description">描述:</label>
            <textarea id="description" name="description" rows="3"></textarea>
        </div>

        <button type="submit">添加商品</button>
    </form>

    <!-- 商品列表 -->
    <h2>商品列表</h2>
    <div id="loading">加载中...</div>
    <table id="productTable">
        <thead>
        <tr>
            <th>商品ID</th>
            <th>商品名称</th>
            <th>商品类型</th>
            <th>价格</th>
            <th>库存</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <!-- 商品数据将通过JavaScript动态加载 -->
        </tbody>
    </table>
</div>